Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid empty string for scope when inserting/updating #563

Merged
merged 3 commits into from
Mar 10, 2023

Conversation

julien-nc
Copy link
Member

Because oracle replaces it with null.

We could do it differently by allowing null values for the scope column. Any preferred option?

@julien-nc julien-nc added the bug Something isn't working label Jan 16, 2023
@julien-nc julien-nc mentioned this pull request Feb 23, 2023
…eplaces it with null

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
@julien-nc
Copy link
Member Author

Simpler and better now, right?

#[\ReturnTypeWillChange]
public function jsonSerialize() {
return [
'id' => $this->id,
'identifier' => $this->identifier,
'clientId' => $this->clientId,
'discoveryEndpoint' => $this->discoveryEndpoint,
'scope' => $this->scope,
'scope' => trim($this->scope),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'scope' => trim($this->scope),
'scope' => trim($this->getScope()),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also move the trim inside the getter then ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think we can't. It seems when updating/inserting a row in the DB, the value that is put there is accessed via the getter. So if we trim there, we will insert/update with an empty string which is what we want to avoid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, fair enough then

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why do you think we should use the getter in jsonSerialize? For empty scopes, the getter will replace it by a space and then we trim it anyway.

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
@juliusknorr juliusknorr merged commit 3ad38d6 into main Mar 10, 2023
@juliusknorr juliusknorr deleted the fix/noid/oracle-empty-string branch March 10, 2023 15:41
@julien-nc julien-nc mentioned this pull request Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants